#include <allegro.h>
#include "jardin.h"

int main() {

int j=0,w=0;
int z=5;
int t=715;
perso *per;
per->x=50;
per->y=200;
BITMAP *Image_j;

BITMAP *obstacle11;
BITMAP *obstacle22;
BITMAP *obstacle33;	
BITMAP *Buffer;
BITMAP *Background;
//BITMAP *coeurs[6];
//BITMAP *vie;
//BITMAP *game_over;	



	


allegro_init();
if (install_keyboard() == -1) {
allegro_message("Error! %s", allegro_error);
return -1;
}
set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0) != 0) 
{
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); 
allegro_message("Unable to initialize video mode!\n%s\n", allegro_error);
return 1;
}



Buffer=create_bitmap(800,600);

int position=0;
Background = load_bitmap("garden2.bmp", NULL);
chargementImage(per);
Image_j=per->img_right[0];

if (Background == NULL) {
allegro_message("could not load images");
allegro_exit();
}
if (Image_j == NULL) {
allegro_message("could not load images");
allegro_exit();
}

	obstacle11=load_bitmap("obstacle1.bmp",NULL);
	obstacle22=load_bitmap("obstacle2.bmp",NULL);
	obstacle33=load_bitmap("obstacle3.bmp",NULL);
	
	/*coeurs[0]=load_bitmap("vie0.bmp",NULL);
	coeurs[1]=load_bitmap("vie1.bmp",NULL);
	coeurs[2]=load_bitmap("vie2.bmp",NULL);
	coeurs[3]=load_bitmap("vie3.bmp",NULL);
	coeurs[4]=load_bitmap("vie.bmp",NULL);
	coeurs[5]=load_bitmap("vie5.bmp",NULL);
	
	game_over=load_bitmap("game_over.bmp",NULL);*/

//blit(Background, Buffer, position, 0,0 , 0, Background->w, Background->h);

//draw_sprite(Buffer, Image_j,per.x,per.y);

//blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
position=0;

while (!key[KEY_ESC]){

//Background = load_bitmap("garden2.bmp", NULL);
//Image_j=per.img_right[0];
//blit(Background, Buffer, position, 0,0 , 0, Background->w, Background->h);
clear_bitmap(Buffer);


 //Image_j=per.img_right[3];
//if (position==6400-SCREEN_W)
//position=0;
deplacement(per,&j,&position, Buffer,Background, Image_j,obstacle11, obstacle22, obstacle33);



draw_sprite(Buffer, Background,position,0);
draw_sprite(Buffer, per->img_right[j],per->x,per->y);
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
//draw_sprite(Buffer, coeurs[w],t,z);

}


return 0;
}
END_OF_MAIN();
